package com.bayihouse.model.vo;

import com.bayihouse.model.entity.Administer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class AdministerVO implements Serializable {

    private static final long serialVersionUID = -8034154413527311401L;
    /**
     * id
     */
    private Long id;

    /**
     * 账号
     */
    private String userAccount;


    /**
     * 用户昵称
     */
    private String userName;


    /**
     * 用户头像
     */
    private String userAvatarUrl;

    /**
     * 用户简介
     */
    private String userProfile;

    /**
     * 用户角色：user/admin/ban
     */
    private Integer userRole;

    /**
     * 创建时间
     */
    private String createTime;


    /**
     * 电话号码
     */
    private String telephone;


    public static AdministerVO objToVo(Administer administer) {
        AdministerVO administerVO = new AdministerVO();
        BeanUtils.copyProperties(administer, administerVO);
        Date createTime1 = administer.getCreateTime();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String format = simpleDateFormat.format(createTime1);
        administerVO.setCreateTime(format);
        return administerVO;
    }


    public static Administer voToObj(AdministerVO administerVO) {
        Administer administer = new Administer();
        BeanUtils.copyProperties(administerVO, administer);
        return administer;
    }


}
